import java.util.*;


public class Main {
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        // 数组长度
        int n = scanner.nextInt();
        // 目标丑数下标
        int t = scanner.nextInt();
        // 接收质数数组
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        // 创建与质数数组同规模大小的数组，用于记录在丑数数组中的遍历记录
        int[] record = new int[n];
        // 创建丑数数组
        int[] prefix = new int[t+1];
        prefix[0] = 1;

        for (int i = 1; i <= t; i++) {
            // 外层循环枚举丑数
            int tmp = (int)Math.pow(2, 31) - 1;
            for (int j = 0; j < n; j++) {
                while (nums[j] * prefix[record[j]] <= prefix[i-1]) {
                    record[j] += 1;
                }
                tmp = Math.min(tmp, nums[j] * prefix[record[j]]);
            }
            prefix[i] = tmp;
        }
        System.out.println(prefix[t]);
    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        // 1 接收输入
        List<String> p = new ArrayList<>();

        while (scanner.hasNext()) {
            String enter = scanner.next();
            // 不为分割点时，将其添加到集合p中
            if (!enter.equals(".")) {
                p.add(enter);
            } else break;
        }

        // 2 开始dp
        StringBuilder s = new StringBuilder();
        while (scanner.hasNext()) {
            String tmp = scanner.nextLine();
            s.append(tmp);
        }

        // (1) 接收数据
        int n = s.length();
        // 预处理字符串，使下标一一映射
        s.insert(0, " ");
        //（2） 创建dp表并完成初始化
        boolean[] dp = new boolean[n + 1];
        dp[0] = true;
        // (3) 开始填表
        int lastIndex = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < p.size(); j++) {
                String tmp = p.get(j);
                int tmpLen = tmp.length();
                if (tmpLen <= i && dp[i - tmpLen] && tmp.equals(s.substring(i - tmpLen+1, i+1))) {
                    dp[i] = true;
                    lastIndex = i;
                    break;
                }
            }
        }
        System.out.println(lastIndex);
    }


    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int n = s.length();
        // 特判 - 长度为1时，不存在出现两次的最长子串
        if (n == 1) {
            System.out.println(0);
            return;
        }
        // 暴力枚举
        for (int interval = n-2; interval >= 0; interval--) {
            int left = 0;
            int right = interval;
            HashMap<String, Integer> dict = new HashMap<>();
            while (right < n) {
                String tmp = s.substring(left, right+1);
                if (dict.containsKey(tmp)) {
                    dict.put(tmp, dict.get(tmp) + 1);
                    if (dict.get(tmp) >= 2) {
                        System.out.println(tmp.length());
                        return;
                    }
                } else {
                    dict.put(tmp, 1);
                }
                left ++;
                right ++;
            }
        }
        System.out.println(0);
    }

    public static void main4(String[] args) {
        // 1 接收数据
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            dp[i] = scanner.nextInt();
        }
        // 2 求前缀和
        int[] f = new int[n];   // f[i]表示以i下标元素为结尾的最长非减子数组长度
        int[] g = new int[n];   // g[i]表示以i下标为开始的最长非增子数组的长度

        Arrays.fill(f, 1);
        Arrays.fill(g, 1);
        for (int i = 1; i < n; i ++) {
            if (dp[i] >= dp[i-1]) {
                f[i] += f[i-1];
            }
        }
        for (int i = n-2; i >= 0; i--) {
            if (dp[i] >= dp[i+1]) {
                g[i] += g[i+1];
            }
        }
        int maxValue = 0;
        for (int i = 0; i < n; i++) {
            if ((f[i] + g[i] - 1) > maxValue) {
                maxValue = f[i] + g[i] - 1;
            }
        }
        System.out.println(maxValue);
    }


//    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        int n = scanner.nextInt();
//        int d = scanner.nextInt();
//        int m = scanner.nextInt();
//        int l = scanner.nextInt();
//        // 1 创建数组
//        // 最后一个位置左端点
//        int maxIndex = (n-1) * m + l + l + d;
//        int[] dp = new int[maxIndex];
//        //2 预处理
//        for (int k = 1; k <= n; k++) {
//            int a = (k-1) * m;
//            int b = a + l;
//            Arrays.fill(dp, a, b+1, -1);
//        }
//        for (int x: dp) System.out.println(x);
//        //3 开始遍历
//        int lastIndex = 0;
//        for (int i = d; i < maxIndex; i += d) {
//            lastIndex = i;
//            if (dp[i] != -1) {
//                System.out.println(i);
//                return;
//            }
//        }
//        System.out.println(lastIndex + d);
//    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int d = scanner.nextInt();
        int m = scanner.nextInt();
        int l = scanner.nextInt();
        int record = ((n-1)*m+l) / d;
        for (int i = 1; i <= n; i++) {
            int a = (i-1) * m + l;
            int b = i * m - 1;
            if (a / d != b / d) {
                record = a / d;
                break;
            }
        }
        System.out.println((record + 1) * d);
    }
}